﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NDF.DataAccess.Sql;
using System.Data;
using NDF.DataAccess.Common;
using System.Data.Common;

namespace NDF.Test.DataAccess
{
    [TestClass]
    public class SqlDatabaseTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            //SqlDatabase database = new SqlDatabase(@"server=.;database=BayGUI;uid=sa;pwd=pas2word@szcp");
            //Database database = DatabaseFactory.Default.CreateDatabase();
            Database database = DatabaseFactories.CreateDatabase("SqlServerContextTest");
            //DataTable table = database.ExecuteDataTable("SELECT * FROM BoxData");
            DataTable table = database.ExecuteDataTable("SELECT * FROM dbo.Sys_Users");
            foreach (DataRow row in table.Rows)
            {
                Console.WriteLine(row["Name"]);
            }
        }

        [TestMethod]
        public void TestMethod2()
        {
            Database database = DatabaseFactories.CreateDatabase("SqlServerContextTest");
            DataTable table = database.ExecuteDataTable("SELECT * FROM dbo.Sys_Users WHERE Name LIKE N'%' + @name + N'%'", "管");
            foreach (DataRow row in table.Rows)
            {
                Console.WriteLine(row["Name"]);
            }
        }
    }
}
